package ldh.im.server.file.handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class FileReceiveHandler extends SimpleChannelInboundHandler<ByteBuf> {

//    private TransferFile transferFile = null;

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
        if (msg.readableBytes() < 4) return;
        msg.markReaderIndex();
        int length = msg.readInt();
        if(msg.readableBytes() < length) return;
        ByteBuf byteBuf = ctx.alloc().buffer();
        msg.readBytes(byteBuf, length);

    }
}
